package groep3.ssc.skaterViews;

import groep3.ssc.helpers.DataFunctions;
import groep3.ssc.main.R;
import groep3.ssc.model.Race;
import android.content.Context;
import android.content.res.Resources;
import android.widget.TextView;

public class LastRoundTimeView extends SkaterViewTemplate
{
    public TextView lastRoundTime;

    public LastRoundTimeView(Context context)
    {
        super(context);
        lastRoundTime = new SkaterTextView(context);
        addView(lastRoundTime);
        subscribeToController();
    }

    @Override
    public void update(Race model)
    {
        Resources res = getResources();
        String txtRoundAbbreviationString = res.getString(R.string.txtRoundAbbreviationString);
        this.lastRoundTime.setText(txtRoundAbbreviationString + " "
                + DataFunctions.longToFormattedTime(model.getSkater(model.getOurSkater()).getLastLapTime()));
    }

    @Override
    public String toString()
    {
        Resources res = getResources();
        String lastRoundTimeString = res.getString(R.string.txtLastRoundTimeString);
        return lastRoundTimeString;
    }
}